﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DAL;

/// <summary>
/// Summary description for GetData
/// </summary>
public class GetData
{
    Process pro;
    public GetData()
	{
        pro = new Process();
	}


    public List<LoaiSP> LoadLoaiSP()
    {
        pro = new Process();
        List<LoaiSP> list = new List<LoaiSP>();
        list = pro.GetAllLoaiSP();
        return list;
    }

    public List<NhaSX> LoadLoaiNSX()
    {
        pro = new Process();
        List<NhaSX> list = new List<NhaSX>();
        list = pro.GetAllNSX();
        return list;
    }

    

    public List<SanPham> GetSanPham(int maLoaiSp)
    {
        pro = new Process();
        List<SanPham> listResult = new List<SanPham>();
        listResult = pro.GetSanPhamByMLSP(maLoaiSp);
        return listResult;
    }

    public List<SanPham> GetSanPhamByNSX(int maNSX)
    {
        pro = new Process();
        List<SanPham> listResult = new List<SanPham>();
        listResult = pro.GetSanPhamByNSX(maNSX);
        return listResult;
    }

    public List<SanPham> GetAllSP()
    {
        pro = new Process();
        List<SanPham> listResult = new List<SanPham>();
        listResult = pro.GetAllSP();
        return listResult;
    }
    

    public KhachHang Login(string userName, string password)
    {
        pro = new Process();
        KhachHang kh = new KhachHang();
        kh = pro.Login(userName, password);
        return kh;
    }

    public KhachHang TaoMoiKhachHang(KhachHang objKhachHang)
    {
        pro = new Process();
        if (objKhachHang.MaKH>0)
        {
            pro.UpdataKhacHang(objKhachHang);
        }
        else
        {
            pro.InserKhachHang(objKhachHang);
        }
        return objKhachHang;
    }

    public GioHang TaoMoiGioHang(GioHang objGioHang)
    {
        pro = new Process();
        pro.TaoMoiGioHang(objGioHang);
        return objGioHang;
    }

    public ChiTietGioHang TaoMoiChiTietGioHang(ChiTietGioHang objChiTietGioHang)
    {
        pro = new Process();
        pro.TaoMoiChiTietGioHang(objChiTietGioHang);
        return objChiTietGioHang;
    }

    public Banking LoginToBanking(string userName, string password)
    {
        pro = new Process();
        Banking kh = new Banking();
        kh = pro.GetBanking(userName, password);
        return kh;
    }

    public KhachHang GetObjectByID(int id)
    {
        pro = new Process();
        return pro.GetObjectByID(id);
    }

    public KhachHang GetObjectByUserName(string userName)
    {
        pro = new Process();
        return pro.GetObjectByUserName(userName);
    }

    public Banking CapNhatSoTienNganHang(Banking objBanking)
    {
        pro = new Process();
       return pro.UpdateBanking(objBanking);
    }

    public List<SanPham> LoadSPByName(string tenSp)
    {
        pro = new Process();
        return pro.GetSPByName(tenSp);
    }

    //public LoaiSP TaoMoiLoaiSP(LoaiSP objLoaiSP)
    //{
    //    pro = new Process();
    //    if (objLoaiSP.MaLoaiSP > 0)
    //    {
    //        pro.UpdataLoaiSP(objLoaiSP);
    //    }
    //    else
    //    {
    //        pro.InsertLoaiSP(objLoaiSP);
    //    }
    //    return objLoaiSP;
    //}

    public SanPham TaoMoiSanPham(SanPham objSanPham)
    {
        pro = new Process();
        if (objSanPham.MaSP > 0)
        {
            pro.UpdateSanPham(objSanPham);
        }
        else
        {
            pro.InsertSanPham(objSanPham);
        }
        return objSanPham;
    }
}